﻿using Gp.Scripts.Core;
using QFramework;
using UnityEngine;
using UnityEngine.UI;

namespace Gp.Scripts.GUI {
    public class NextTurnButton : MonoBehaviour, IController{
        private Button _button;
        private void Start() {
            _button = this.GetOrAddComponent<Button>();
            this._button.onClick.AddListener(Global.Get<BattleSystem>().NextTurn);

            this.RegisterEvent<TurnResolveEvent>(OnTurnResolve).UnRegisterWhenGameObjectDestroyed(gameObject);
        }

        private void OnTurnResolve(TurnResolveEvent e) {
            _button.interactable = e.CurrentPlayer is HumanPlayer;
        }

        public IArchitecture GetArchitecture() {
            return MainArchitecture.Interface;
        }
    }
}